package yannan.voiplock4ble.base;

import android.app.Application;

import com.tencent.bugly.crashreport.CrashReport;
import com.umeng.analytics.MobclickAgent;

import org.greenrobot.eventbus.EventBus;

import yannan.voiplock4ble.bean.UserBean;
import yannan.voiplock4ble.bean.ble.ConnectLock;
import yannan.voiplock4ble.db.AbstractDBHelper;


/**
 * 说明：
 * 作者：mainTel
 * 时间：2016/8/23 17:49
 * 备注：
 */
public class MyApplication extends Application {

    private static MyApplication app;

    public UserBean userBean;

    public ConnectLock mConnectLock;
    public static boolean isHaveConnected=false;

    public static MyApplication getInterface() {
        return app;
    }

//    public List<Activity> activityList = new ArrayList<>();
//    public Map<String, LoggedBaseActivity> activityMap = new HashMap<>();

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        AbstractDBHelper.initDBHelper(getApplicationContext());
        CrashReport.initCrashReport(getApplicationContext(), "9cf25c6ada", true);
        EventBus.builder().installDefaultEventBus();
        MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
    }

    //关闭每一个list内的activity
    public void exit() {
        try {
//            for (Map.Entry<String, LoggedBaseActivity> item :
//                    activityMap.entrySet()) {
//                item.getValue().finish();
//            }
//            for (Activity activity : activityList) {
//                if (activity != null)
//                    activity.finish();
//            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
